<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>穿梭框组件</title>
<link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
	<div id="text1"></div>
	<script src="./layui/layui.js"></script>
	<script>
		layui.use(['transfer', 'util', 'layer', 'flow'], function() {
			var $ = layui.jquery,
			transfer = layui.transfer,
			util = layui.util,
			flow = layui.flow,
			layer = layui.layer;
			/* 
			穿梭框  注意：返回格式必须以key、value形式，所以后台用了map
			*/
			$.post('/selectAllName',function(data){
				transfer.render({
					  title :['角色','已选角色']
					  ,elem: '#text1'
					  ,data: data //数据源
					  ,onchange: function(data, index){
						    console.log(data); //得到当前被穿梭的数据
						    console.log(index); //如果数据来自左边，index 为 0，否则为 1
						  }
					  ,parseData: function(data){
					    return {
					      "value": data.rid //数据值
					      ,"title": data.rname //数据标题
					      ,"disabled": data.disabled  //是否禁用
					      ,"checked": data.checked //是否选中
					    }
					  }
					});
			})
			
		
		});
	</script>
</body>
</html>